package com.haiertvbic.tvwa;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.haiertvbic.tvwa.model.FavChannelBean;

public class MyFavChasAdapter extends BaseAdapter{
	private Context context;
	private ArrayList<FavChannelBean> favChannels;
	private LayoutInflater inflater;
	public MyFavChasAdapter(Context context,ArrayList<FavChannelBean> favChannels){
		this.context = context;
		this.favChannels = favChannels;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return favChannels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return favChannels.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView == null){
			convertView = inflater.inflate(R.layout.channel_item, null);
		}
		TextView chaIndex = (TextView) convertView.findViewById(R.id.channel_id);
		TextView chaName = (TextView) convertView.findViewById(R.id.channel_name);
		chaIndex.setText(""+(position+1));
		chaName.setText(favChannels.get(position).getChannel_name());
		return convertView;
	}

}
